﻿using FluentAssertions;
using System;
using System.Collections.Generic;
using System.Linq;
using Xunit;

namespace Sustainalytics.ScreeningTool.Synchronization.Tests.Extensions.StringExtensionsTests
{
    [Trait("Category", "Unit")]
    public class StripHtmlTags_Should
    {
        [Fact]
        public void return_null_for_null_value()
            => ((string)null).StripHtmlTags().Should().Be(null);

        [Fact]
        public void return_empty_string_for_empty_string_value()
            => "".StripHtmlTags().Should().Be("");

        [Fact]
        public void return_value_unchanged_if_value_has_no_html_tags()
            => "bla".StripHtmlTags().Should().Be("bla");

        [Fact]
        public void remove_self_closing_html_tags_from_value()
            => "bla<br />bla".StripHtmlTags().Should().Be("blabla");

        [Fact]
        public void remove_html_tags_from_value()
            => "bla<b>bla</b>bla".StripHtmlTags().Should().Be("blablabla");

        [Fact]
        public void return_text_inside_html_tags_from_value()
            => "<b>bla</b>".StripHtmlTags().Should().Be("bla");

        [Fact]
        public void return_text_inside_nested_html_tags_from_value()
            => "<p>bla<b>bla</b>bla</p>".StripHtmlTags().Should().Be("blablabla");

        [Fact]
        public void keep_unescaped_less_than_characters_in_value()
            => "bla < 0<br />".StripHtmlTags().Should().Be("bla < 0");

        [Fact]
        public void keep_unescaped_less_than_characters_inside_html_tag_in_value()
            => "<b>bla < 0</b>".StripHtmlTags().Should().Be("bla < 0");

        [Fact]
        public void keep_unescaped_greater_than_characters_in_value()
            => "bla > 0<br />".StripHtmlTags().Should().Be("bla > 0");

        [Fact]
        public void keep_unescaped_greater_than_characters_inside_html_tag_in_value()
            => "<b>bla > 0</b>".StripHtmlTags().Should().Be("bla > 0");

        [Fact]
        public void keep_percentile_characters_inside_html_tag_in_value()
            => "<b>bla 10%</b>".StripHtmlTags().Should().Be("bla 10%");

        [Fact]
        public void decode_html_characters_from_value()
            => "&lt;&gt;".StripHtmlTags().Should().Be("<>");
    }
}
